﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using COM.OA.BLL;
using COM.OA.Entity;
using System.Collections.Generic;

public partial class qunfa : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
      
    }

    protected void Button3_Click(object sender, EventArgs e)
    {
        //清空文本框
        this.txtbiaoti.Text = "";
        this.FreeTextBox1.Text = "";
    }
    protected void btn_fasong_Click(object sender, EventArgs e)
    {
        //取文本框值
        string biaoti = this.txtbiaoti.Text;
        string neirong = this.FreeTextBox1.Text;
        //判断是否为空
        if (biaoti == null || biaoti == "")
        {
            this.Response.Write(string.Format(GetRedirect.WINALERT, "标题不能为空"));
            this.txtbiaoti.Focus();
            return;
        }
        if (neirong == null || neirong == "")
        {
            this.Response.Write(string.Format(GetRedirect.WINALERT, "内容不能为空"));
            this.FreeTextBox1.Focus = true;
            return;
        }
        else
        {

            string bumen = this.Dropbumen.Text;
            //格式化 传参
            string where = "u_dept_id='{0}'";
            where = string.Format(where, bumen);
            //查询该部门所有人
            IList<users> list = usersBLL.Select(where);
            //循环发送
            foreach (users uu in list)
            {
                message me = new message();
                me.m_sendu_id = 1;
                me.m_content = neirong;
                me.m_title = biaoti;
                me.m_u_id = uu.u_id;
                me.m_g_id = 1;
                me.m_releasetime = DateTime.Now;
                //插入数据库 
                messageBLL.Insert(me);


            }
            this.Response.Write(string.Format(GetRedirect.WINALERT, "群发成功"));
        }
    }
 
}
